package sample.templates;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;

public class parseTrash {
	public static void fillBin(String filename,Fillable bin) throws Exception{
		try {
			BufferedReader data=new BufferedReader(new FileReader(filename));
			String buf;
			try {
				while((buf=data.readLine())!=null){
					String type=buf.substring(0,buf.indexOf(":")).trim();
					double weight=Double.valueOf(buf.substring(buf.indexOf(":")+1).trim()).doubleValue();
					bin.addTrash(Trash2.factory(new Trash2.Info(type,weight)));
							
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			try {
				data.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		
	}
	public static void fillBin(String filename,Vector bin) throws Exception{
		fillBin(filename,new FillableVector(bin));
	}
}
